﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EmbeddedSharp.Core.Function.Expressions {
    public class InverseNode : FuncNode {

        public InverseNode()
            : base()
        {
            base.Value = "inverse";
        }

        public override object Evaluate() {
            if (Parameters.Count < 1) {
                throw new Exception("usage: inverse(funcName)");
            }

            if (Parameters[0] is FuncNode) {
                FuncNode fn = Parameters[0] as FuncNode;
                return fn.DefaultReversedFunction;
            } else {
                throw new Exception("Argument is not a function node and thus cannot be reversed.");
            }
        }
    }
}
